<!--
 * @Author: your name
 * @Date: 2022-04-12 09:16:04
 * @LastEditTime: 2022-04-12 09:33:05
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\删除数组的制定下标元素220412.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>删除数组的指定下标元素</title>
</head>
<body>
  <script>
  Array.prototype.del=function(index){
    if(isNaN(index)||index>=this.length){
      return false;
    }
    for(var i=0,n=0;i<this.length;i++){
      if(this[i]!=this[index]){
        this[n++]=this[i];
      }
    }
    this.length-=1;
    return this
  };

  var geyao=["1","2","3"]
  console.log(geyao.del(1))//["1","3"]
  </script>
</body>
</html>